﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;

namespace ResizeImage
{
	class Program
	{
		static void Main(string[] args)
		{
			string file=@"d:\tmp\scr.jpg";

			using (Image img = Image.FromFile(file))
			{
				Size[] newSizes = new Size[] { new Size(1536, 2008), new Size(1242, 2008), new Size(750, 1334), new Size(640, 1096), new Size(658, 1096), new Size(640, 920), new Size(660, 920), new Size(1080, 1680) };

				foreach (Size newSize in newSizes)
				{
					using (Bitmap cpy = new Bitmap(newSize.Width, newSize.Height, PixelFormat.Format32bppArgb))
					{
						using (Graphics gr = Graphics.FromImage(cpy))
						{
							gr.Clear(Color.Transparent);

							// This is said to give best quality when resizing images
							gr.InterpolationMode = InterpolationMode.HighQualityBicubic;

							Point leftTop = new Point(0, 0);
							gr.DrawImage(img,
								new Rectangle(leftTop, newSize),
								new Rectangle(leftTop, img.Size),
								GraphicsUnit.Pixel);
						}

						string newFileName = "vendor3_" + newSize.Width.ToString() + "x" + newSize.Height.ToString() + ".jpg";
						cpy.Save(Path.Combine(@"D:\MyWebs\golliedeal\trunk\Gollie.App\Gollie.App\Screenshots", newFileName), ImageFormat.Jpeg);
					}
				}
			}
		}
	}
}
